<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>FileMigration</title>
    <link rel="stylesheet" type="text/css" href="https://www.layuicdn.com/layui/css/layui.css" />
    <style>
        .layui-header{height:50px}
        .layui-layout-admin .layui-logo{line-height:50px;height:50px;font-size:18px}
        .layui-nav layui-layout-right{line-height:50px;height:50px}
        .layui-layout-admin .layui-side{top:50px}
        .layui-layout-admin .layui-body{top:50px}
        .pp-nav-item{line-height:50px!important;height:50px!important}
        .pp-nav-child a{line-height:30px!important;height:30px!important}
        .pp-nav-item a{line-height:50px;height:50px}
        .layui-nav .layui-nav-item .layui-nav-itemed{line-height:50px;height:50px}
        .layui-nav-child{top:50px}
        .layui-layout-admin .layui-footer{line-height:35px;height:35px}
        .pp-side-fold{height:30px;background-color:#4a5064;color:#aeb9c2;line-height:30px;text-align:center;cursor:pointer}
        .back_space1{margin-right:5px}
        a.pointer{cursor:pointer}
        .pp-ddsided{width:50px}
        a.pp-pointer{padding-right:0!important}
        .pp-sided{width:50px}
        .pp-main{left:50px!important}
        .pp-tab{margin-top:0}
        .pp-tab-title{background:#000}
        .layui-this{background:#fff}
        .layui-tab-title li.pp-tab-li{border:0}
    </style>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">&nbsp;&nbsp;&nbsp;&nbsp;FileMigration<font style="font-size: 12px"> version1.0</font></div>
        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-nav layui-layout-left">
        </ul>
        <ul class="layui-nav layui-layout-right pp-nav-item" >
            <li class="layui-nav-item"><a href="http://github.com/cilidm" target="_blank">GitHub</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black pp-side">
        <div class="layui-side-scroll" style="width: 100%">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree"  lay-filter="nav-side">
                <li class="layui-nav-item layui-nav-itemed layui-this">
                    <a data-url="/" data-icon="fa-home" data-title="系统首页" data-id="0" class="pointer">
                        <i class="fa fa-home back_space1"></i><span>全部文件</span>
                    </a>
                </li>
{{/*                <li class="layui-nav-item">*/}}
{{/*                    <a class="" href="javascript:;">*/}}
{{/*                        <i class="fa fa-home"></i> &nbsp;&nbsp;<span>查看文件</span>*/}}
{{/*                    </a>*/}}
{{/*                    <dl class="layui-nav-child pp-nav-childs">*/}}
{{/*                        <dd>*/}}
{{/*                            <a data-url="/index" data-icon="fa fa-home" data-title="全部文件" class="pointer" data-id="1">*/}}
{{/*                                <i class="fa fa-home"></i>  &nbsp;&nbsp;<span>全部文件</span>*/}}
{{/*                            </a>*/}}
{{/*                        </dd>*/}}
{{/*                        <dd>*/}}
{{/*                            <a data-url="/pic" data-icon="fa fa-home" data-title="图片文件" class="pointer" data-id="2">*/}}
{{/*                                <i class="fa fa-home"></i>  &nbsp;&nbsp;<span>图片文件</span>*/}}
{{/*                            </a>*/}}
{{/*                        </dd>*/}}
{{/*                        <dd>*/}}
{{/*                            <a data-url="/video" data-icon="fa fa-home" data-title="视频文件" class="pointer" data-id="3">*/}}
{{/*                                <i class="fa fa-home"></i>  &nbsp;&nbsp;<span>视频文件</span>*/}}
{{/*                            </a>*/}}
{{/*                        </dd>*/}}
{{/*                        <dd>*/}}
{{/*                            <a data-url="/file" data-icon="fa fa-home" data-title="文件展示" class="pointer" data-id="4">*/}}
{{/*                                <i class="fa fa-home"></i>  &nbsp;&nbsp;<span>文件展示</span>*/}}
{{/*                            </a>*/}}
{{/*                        </dd>*/}}
{{/*                    </dl>*/}}
{{/*                </li>*/}}
            </ul>
        </div>
    </div>

    <div class="layui-body" style="overflow: hidden;">
        <!-- 内容主体区域 -->
        <div class="layui-tab pp-tab" lay-filter="main_tab" lay-allowClose="true">
            <ul class="layui-tab-title" style="background: #efefef">
                <li class="pp-tab-li layui-this" id="default_tab" lay-id="0"><i class="fa fa-home back_space1"></i>重复文件</li>

            </ul>
            <div class="layui-tab-content" style="padding: 0px; ">
                <div class="layui-tab-item layui-show" style="margin: 0px;overflow:hidden;">
                    <iframe src="/index" frameborder="0" scrolling="yes"></iframe>
                </div>

            </div>
        </div>
    </div>

    <div class="layui-footer" style="border-top: 2px solid #e4e4e4">
        <!-- 底部固定区域 -->
        © Power by <a href="http://www.github.com/" target="_blank">.version</a>
    </div>
</div>
<script src="https://www.layuicdn.com/layui/layui.js"></script>
<script>
    //JavaScript代码区域
    var $;
    var element;
    var width,height;

    function delHtmlTag(str){
        return str.replace(/<[^>]+>/g,"");//去掉所有的html标记
    }

    function getDelimiterLastString(str,delimiter) {
        arr = str.split(delimiter);
        if (arr.length>1){
            return arr[arr.length-1];
        }
        return str;
    }

    //新页面编辑或者新增，完成后关闭本页并刷新上一页
    function deleteCurrentTab(){
        //关闭
        var lay_id = $(parent.document).find("ul.layui-tab-title").children("li.layui-this").find(".layui-tab-close");
        lay_id.click();

        //刷新
        var currents =$(parent.document).find("div.layui-tab-content").find("div.layui-show").find("iframe").contents();
        $(currents[0]).find("body").find("#reload").click();
    }

    function getCheckboxValue(name)
    {
        var arr = new Array();
        $("input:checkbox[name="+name+"]:checked").each(function(){
            console.log($(this).val());
            arr.push($(this).val());
        });

        return arr.join(",");
    }


    function openTab(url,title,id,icon){

        if (!url || !title || !id) {
            return;
        }

        if (!icon) {
            icon = " fa-clock-o ";
        }
        //判断是否存在
        var is_exist = 0;
        $(".layui-tab-title").find("li").each(function(){
            var nav_id = $(this).attr("lay-id");
            if (nav_id==id) {
                is_exist = 1
            }
        })

        if (is_exist==1) {
            element.tabChange("main_tab", id);
        }else{
            var content = '<iframe src="'+url+'" scrolling="yes" width="'+width+'" height="'+height+'" frameborder="0"></iframe>';
            title = '<i class="fa '+icon+' back_space1"></i>'+title;
            element.tabAdd('main_tab', {
                title: title
                ,content: content //支持传入html
                ,id: id
            });

            element.tabChange("main_tab", id);
        }
    }

    layui.use(['element','jquery','layer'], function(){
        element = layui.element;
        $ = layui.jquery;
        var layer = layui.layer;

        //frame大小适应开始
        resizeFrame();
        window.onresize = function(){
            resizeFrame();
        }
        function resizeFrame()
        {
            height = $(".layui-body").height()-40;
            width = $(".layui-body").width();
            $(".ayui-tab-content").width(width);
            $(".ayui-tab-content").height(height);
            $(".layui-tab-item").height(height);
            $(".layui-tab-item").find("iframe").height(height);
            $(".layui-tab-item").find("iframe").width(width);
        }
        //frame大小适应结束

        //左侧菜单栏缩放
        $('.pp-side-fold').on('click',function(){
            var side_width = $(".layui-side").width();
            if (side_width>50) {
                $(".layui-side").width(50);
                $(this).parent().find('span').hide();
                $(".layui-body").addClass('pp-main');
                $(".layui-footer").addClass('pp-main');
                $(".layui-nav-child").find('dd').addClass('pp-ddsided');
                $(".layui-nav-child").find('a').addClass('pp-pointer');
                resizeFrame();
            }else{
                $(".layui-side").width(200);
                $(this).parent().find('span').show();
                $(".layui-body").removeClass('pp-main');
                $(".layui-footer").removeClass('pp-main');
                $(".layui-nav-child").find('dd').removeClass('pp-ddsided');
                $(".layui-nav-child").find('a').removeClass('pp-pointer');
                resizeFrame();
            }
        })

        //添加标签
        element.on('nav(nav-side)', function(elem){
            var url = elem.attr('data-url');
            var title = elem.attr('data-title');
            var id = elem.attr('data-id');
            var icon = elem.attr('data-icon');

            if (!url || !title || !id) {
                return;
            }
            //判断是否存在
            var is_exist = 0;
            $(".layui-tab-title").find("li").each(function(){
                var nav_id = $(this).attr("lay-id");
                if (nav_id==id) {
                    is_exist = 1
                }
            })

            if (is_exist==1) {
                element.tabChange("main_tab", id);
            }else{
                var content = '<iframe src="'+url+'" scrolling="yes" width="'+width+'" height="'+height+'" frameborder="0"></iframe>';
                title = '<i class="fa '+icon+' back_space1"></i>'+title;
                element.tabAdd('main_tab', {
                    title: title
                    ,content: content //支持传入html
                    ,id: id
                });

                element.tabChange("main_tab", id);
            }
        });

        //tab标签选中，菜单栏状态
        $(".layui-tab-title").on("click","li",function(){
            var id = $(this).attr('lay-id');
            if (!id) {return;}
            var sid = 0;
            $(".layui-nav-item").find("a").each(function(){
                sid = $(this).attr("data-id");
                if (sid==id) {
                    $(this).click();
                }
            })
        })

        //tips
        $(".pp-nav-childs").find('a').hover(function(){
            layer.tips($(this).attr('data-title'), $(this),{time:1000});
        });




        element.render();
        // $("#default_tab").html('<i class="fa fa-home back_space1"></i>系统首页');

    });
</script>
</body>
</html>